(function() {

    function showPageAction(tabId) {
        chrome.pageAction.show(tabId);
        chrome.pageAction.onClicked.addListener(function(tab) {
            window.open("gift.html", "RCGiftTokenTool");
        });
    }

    function main() {
        // on receiving session data from content script
        chrome.extension.onRequest.addListener(function(request, sender, sendResponse) {
            if (request["status"] === "session") {
                // expose session data to gift page
                window.session = request;
                showPageAction(sender.tab.id);
            }
        });
    }

    main();

})();